<!--  -->
<template>
  <div class="tabItem" @click="handleChange()">
    <div v-if="!isActive"><slot name="icon"></slot></div>
    <div v-else><slot name="icon-o"></slot></div>
    <div :style="activeStyle"><slot name="text"></slot></div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    path: String,
    activeColor: {
      type: String,
      default: "palevioletred"
    }
  },
  data() {
    return {};
  },
  computed: {
    isActive() {
      return this.$route.path.indexOf(this.path) !== -1;
    },
    activeStyle() {
      return this.isActive ? { color: this.activeColor } : {};
    }
  },
  watch: {},
  methods: {
    handleChange() {
      this.$router.replace(this.path);
    }
  },
  created() {},
  mounted() {},
  updated() {}
};
</script>
<style lang="less" scoped>
.tabItem {
  flex: 1;
  text-align: center;
  font-size: 14px;
  img {
    width: 25px;
    height: 25px;
  }
}
</style>
